<?php
/* Description: This file is used to add sub sub category. */
#########IncludeFiles####################################################################################
include_once '../inc/config.php';
include_once("../inc/bootstrape.php");
require_once _SITE_PATH_.'classes/Vendor/Vendor.php';
require_once _SITE_PATH_.'classes/Master/Master.php';
require_once _SITE_PATH_.'classes/Product/Product.php';
require_once _SITE_PATH_.'classes/Content/Content.php';
require_once _SITE_PATH_.'classes/CommonUtility/CommonUtility.php';

$id = trim($_REQUEST['id']);

if( $_POST['submit']=='Submit'){   
	$parms['id'] = $_POST['id'];
	$parms['slug'] = str_replace(' ','-',$_POST['slug']);
	$parms['title'] = $_POST['title'];
	$parms['description'] = $_POST['description'];
	$parms['meta_title'] = $_POST['meta_title'];
	$parms['meta_description'] = $_POST['meta_description'];
	$parms['meta_keywords'] = $_POST['meta_keywords'];
	$parms['added'] = date("Y-m-d h:i:s");
	$parms['modified'] = date("Y-m-d h:i:s");

	// upload and create thumb of the image //
	if( !empty( $_FILES['page_image'] ) ){
		$filename  = 'page_image';     //  this is name of the control you are using in html form
		$module='page_content';
		$uploadedfile = CommonUtility::uploadNcreateThumb($filename, $module, true, 100);
		if( $uploadedfile!= -1 )    {
			$parms['image'] = $uploadedfile;//$_POST['package_image'];
		}
		CommonUtility::removeImage($result['image'], $module);
	}
	
	$condition['id'] = $parms['id'];
	
    if( CommonUtility::updateData($parms, 'page_content', $condition)) {        
        header("Location: page_mng.php?msg=1786");            
        exit;
    }
    $err = 1787;    
}

$editor = CommonUtility::includeEditor();

$page_content = array();
$page_content = Content::getPageContent($id);
$result = $page_content[0];

$errMsg = $err;
$_tplName = 'content/page_edit.tpl';
$_title = 'Edit Page';

require_once _ADMIN_TPL_MAIN_;
?>